<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <g:set var="entityName" value="${message(code: 'estate.label', default: 'Estate')}" />
    <title>押品有效到期监测</title>
    <style>
    .contact-stat{
        padding: 8px 0px;
        text-align: center;
    }
    .contact-stat span{
        font-size: 13px;
        color: #88898c;
        margin-bottom: 10px;
    }
    .contact-stat strong{
        font-size: 13px;
        word-wrap: break-word;
    }
    .nav-tabs{
        border-bottom: none;
    }
    .hpanel > .panel-footer, .hpanel > .panel-section{
        background: #f9f9f9;
    }

    .newFontSize{
        font-size: 12px;
    }
    table>tbody>tr>td, table>tbody>tr>th,.table>tfoot>tr>td, table>tfoot>tr>th, table>thead>tr>td, table>thead>tr>th{
        padding: 8px;
        line-height: 1.42857143;
    }

    </style>
</head>
<body class="fixed-navbar fixed-sidebar">

    <div class="small-header">
        <div class="hpanel">
            <div class="panel-body">
                <div id="hbreadcrumb" class="pull-right">
                    <ol class="hbreadcrumb breadcrumb">
                        <li>CINDATA PLS</li>
                        <li class="active">
                            <span>押品有效到期监测</span>
                        </li>
                    </ol>
                </div>
                <h2 class="font-light m-b-xs">
                    押品有效到期监测
                </h2>
            </div>
        </div>
    </div>

    <div class="content animate-panel">
        <div class="row">
            <g:form method="POST" action="effectiveMaturityWarning" class="form-horizontal" role="form" id="form">
                <div class="hpanel hblue">
                    <div class="panel-heading">
                        <div class="panel-tools">
                            <button class="btn btn-primary btn-xs" type="submit" id="searchBtn"><i class="fa fa-search"></i> 查询</button>
                            <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                                <i class="fa fa-times"></i> 重置</button>
                        </div>
                        查询
                    </div>
                <div class="panel-body seach-group" id="bug1">

                    <div class="row">
                        <div class="form-group col-sm-3">
                            <label  class="col-sm-3 control-label">押品编号</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="externalId" id="externalId" value="${params?.externalId}" placeholder="请输入押品编号">
                            </div>
                        </div>

                        <div class="form-group col-sm-3">
                            <label  class="col-sm-3 control-label">押品名称</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="name" id="name" value="${params?.name}" placeholder="请输入押品名称">
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label  class="col-sm-3 control-label">押品类型</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="type" id="type" from="${com.cindata.dictionary.CollateralType.list()}" optionKey="id" optionValue="name" value="${params?.type}" noSelection="${['': '请选择押品类型']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label  class="col-sm-3 control-label">是否过期</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="expires" id="expires" from="${[[name:'是',value:true],[name:'否',value:false]]}" optionValue="name" optionKey="value" value="${params.expires}" noSelection="${['': '请选择是否过期']}"/>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="form-group col-sm-3">
                            <label  class="col-sm-3 control-label">处置状态</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="status" id="status" from="${com.cindata.dictionary.RiskWarningStatusDict.listOrderById()}" optionKey="id" optionValue="name"
                                      value="${params?.status}" noSelection="${['': '请选择处置状态']}"/>
                            </div>
                        </div>
                    </div>
                </div>
            </g:form>
        </div>
    </div>

    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <!-- <g:link class="btn btn-info btn-xs" action="excuteComponentWithParam" params="[componentCode: 'effectiveMaturity']">发布预警</g:link> -->
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部押品有效到期监测列表
            </div>
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center" id="estateTable">
                        <thead>
                        <tr>
                            <g:sortableColumn property="externalId" title="押品编号" params="${params}"/>
                            <g:sortableColumn property="buildingType" title="押品类型" params="${params}"/>
                            <g:sortableColumn property="colalteralType" title="押品分类" params="${params}"/>
                            <g:sortableColumn property="name" title="押品名称" params="${params}"/>
                            <g:sortableColumn property="fullName" title="抵押人/出质人" params="${params}"/>
                            <!-- <g:sortableColumn property="number" title="所有权证编号"  class=" text-center" params="${params}"/> -->
                            <g:sortableColumn property="latestEvaluatePrice" title="当前评估/认定价值"  class=" text-center" params="${params}"/>
                            <g:sortableColumn property="endDate" title="押品到期日" class=" text-center" params="${params}"/>
                            <g:sortableColumn property="days" title="距离天数" params="${params}"/>
                            <g:sortableColumn property="isPass" title="是否过期" params="${params}"/>
                            <g:sortableColumn property="registerFullName" title="押品登记人"  params="${params}"/>
                            <g:sortableColumn property="registerAccount" title="押品登记机构" params="${params}"/>
                            <g:sortableColumn property="status" title="处置状态" params="${params}"/>
                            <th colspan="2" class="text-center sortable" style="color: #34495e;">操作项</th>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${riskWarningList}">
                            <tr>
                                <td>
                                <g:link style="color: #3498DB" action="effectiveMaturityWarningShow" id="${it?.collateral?.id}" params="[status: it?.status?.name]">${it?.collateral?.externalId}</g:link></td>
                                <td>${it?.collateral?.estate?.buildingType?.name}</td>
                                <td>${it?.collateral?.type?.name}</td>
                                <td>${it?.collateral?.name}</td>
                                <td>${it?.collateral?.fullName}</td>
                                <!-- <td>无</td> -->
                                <td>${it?.collateral?.latestEvaluatePrice}</td>
                                <td><g:formatDate date="${it?.collateral?.estate?.endDate}" format="yyyy-MM-dd"></g:formatDate></td>
                                <td>${it?.collateral?.estate?.endDate - new Date()}</td>
                                <td>${it?.collateral?.estate?.endDate - new Date() < 0 ? '是' : '否'}</td>
                                <td>${it?.collateral?.registerFullName}</td>
                                <td>${it?.collateral?.registerAccount}</td>
                                <td>${it?.status?.name}</td>
                                <g:if test="${it?.status?.name == '已处置'}">
                                    <td class="text-center">
                                        <div style="margin-bottom: 2px;">
                                            <div class="btn btn-xs btn-outline btn-success" style="color: #fff" disabled>
                                                已处置
                                            </div>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <div class="btn btn-xs btn-outline btn-danger" style="width: 52px; margin-top: 2px;color: #fff" disabled>
                                            删除
                                        </div>
                                    </td>
                                </g:if>
                                <g:else>
                                    <td class="text-center">
                                        <div style="margin-bottom: 2px;">
                                            <a href="${it?.id}" class="btn btn-xs btn-outline btn-success handleButton">
                                                已处置
                                            </a>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <a href="${it?.id}" class="btn btn-xs btn-outline btn-danger deleteButton" style="width: 52px; margin-top: 2px;">
                                            删除
                                        </a>
                                    </td>
                                </g:else>
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate action="effectiveMaturityWarning" total="${riskWarningCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(".handleButton").click(function(event){
        event.preventDefault();
        var id = $(this).attr("href");
        swal({
                title: "该笔押品已经完成预警处置吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function(){
                $.ajax({
                    url:'/riskWarning/riskWarningDeal',
                    data:{
                        id:id
                    },
                    type:"post",
                    success:function(data)
                    {
                        if(data.status=="success"){
                            window.location.reload();
                        }else{
                            swal("已处置失败，请稍后重试", "", "error");
                        }
                    }
                })

            });
    });
    $(".deleteButton").click(function(event){
        event.preventDefault();
        var id = $(this).attr("href");
        swal({
                title: "确定删除该笔押品的预警处置吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function(){
                $.ajax({
                    url:'/riskWarning/riskWarningDelete',
                    data:{
                        id:id
                    },
                    type:"post",
                    success:function(data)
                    {
                        if(data.status=="success") {
                           window.location.reload();
                        } else{
                            swal("删除失败，请稍后重试", "", "error");
                        }
                    }
                })
            })
    });

    //条件重置
    $("#resetBtn").click(function () {
        $("#s2id_type span:first").html("请选择押品类型");
        $("#type").val("");
        $("#name").val("");
        $("#externalId").val("");
        $("#s2id_expires span:first").html("请选择是否过期");
        $("#expires").val("");
        $("#status").val("");
        $("#s2id_status span:first").html("请选择处置状态");
    });
</script>

</body>
</html>
